﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace WizzardTheGame
{
    class Object2D
    {
        private float scale;
        private Texture2D sprite;
        private bool isVisible;
        private Rectangle rectangle;
        private Color colorTaint;

        #region Properties

        public Color ColorTaint
        {
            get { return colorTaint; }
            set { colorTaint = value; }
        }

        public float Scale {
            get { return scale; }
            set { scale = value; }
        }

        public Texture2D Sprite {
            get { return sprite; }
            set { sprite = value; }
        }

        public bool IsVisible {
            get { return isVisible; }
            set { isVisible = value; }
        }

        public Rectangle Rectangle {
            get { return rectangle; }
            set { rectangle = value; }
        }

        public int Width
        {
            get { return Rectangle.Width; }
            set
            {
                Rectangle rec = Rectangle;
                rec.Width = value;
                Rectangle = rec;
            }
        }

        #endregion

        public Object2D()
        {
            ColorTaint = Color.White;
            SetPos(0, 0);
            Rectangle = new Rectangle(0, 0, 100, 100);
        }

        public void SetPos(int x, int y)
        {
            Rectangle rect = Rectangle;
            rect.X = x;
            rect.Y = y;
            Rectangle = rect;
        }

        public void SetWidthHeight(int width, int height)
        {
            Rectangle rect = Rectangle;
            rect.Width = width;
            rect.Height = height;
            Rectangle = rect;
        }

        public void LoadContent(String image)
        {
            Sprite = GameWorld.getInstance().Content.Load<Texture2D>(image);
            SetWidthHeight(Sprite.Width, Sprite.Height);
        }

        public void Draw()
        {
            if (IsVisible)
            {
                GameWorld.getInstance().SpriteBatch.Draw(Sprite, Rectangle, null, ColorTaint, 0, Vector2.Zero, SpriteEffects.None, 1);
            }
        }
    }
}
